const mongoose = require("./db")

//登录注册
let userSchema = new mongoose.Schema({
    iphone: String,
    pwd: String,
    spwd: String,
    img: {
        type:String,
        default:"https://img2.baidu.com/it/u=2273023998,1906397527&fm=253&fmt=auto&app=138&f=JPEG?w=475&h=475"
    },         //头像
    name: {
        type:String,
        default:"无"
    },        //名称
    sex: {
        type:String,
        default:"男"
    },         //性别
    test: {
        type:String,
        default:"一起运动一起快乐"
    },        //简介
    km: {
        type:Number,
        default:0
    },          //千米记录
    dynamic: Array,      //我的动态
    interest: Array,     //我的关注
    fans: Array,     //我的粉丝
    collect: Array,      //我的收藏
    togetherrun: Array,  //我的一起跑
    address: {
        type:String,
        default:"人工智能学院"
    },     //我的学院
    groupchat: Array,   //我的群聊
})

//绑定手机号
let phoneSchema = new mongoose.Schema({
    phone: String,
    codes: String
})

//身份验证
let statusSchema = new mongoose.Schema({
    student: String,
    name: String,
})

let phoneModel = mongoose.model('phone', phoneSchema, 'phone');
let statusModel = mongoose.model('status', statusSchema, 'status');
//用户表
// let userSchema = new mongoose.Schema({  
//     yzm:String,          
//     iphone:String,      
//     user:String,        //账号
//     pass:String,        //密码 
//     tel:String,         //手机号
//     img:String,         //头像
//     name:String,        //名称
//     sex:String,         //性别
//     test:String,        //简介
//     km:Number,          //千米记录
//     dynamic:Array,      //我的动态
//     interest:Array,     //我的关注
//     collect:Array,      //我的收藏
//     togetherrun:Array,  //我的一起跑
//     address:String,     //我的学院
//     groupchat:String,   //我的群聊
// })

let userModel = mongoose.model("user", userSchema, "user")

//动态列表jian
let listSchema = new mongoose.Schema({
    img: String,         //图片
    imgs: Array,         //多张图片
    name: String,        //名称
    avatar: String,       //头像
    test: String,        //简介
    time: {              //发布时间
        type: Date,
        default: new Date()
    },
    praisenum: Number,      //点赞量
    praise: {         //赞
        type: Boolean,
        default: false
    },     //赞
    collect: {         //收藏
        type: Boolean,
        default: false
    },
    comment: Array,         //评论
    forwardnum: Number,     //转发量
    address: String,        //学院
})

let listModel = mongoose.model("list", listSchema, "list")


//一起跑列表
let runSchema = new mongoose.Schema({
    img: String,         //图片
    name: String,        //名称
    avatar: String,       //头像
    test: String,        //简介
    time: {              //发布时间
        type: Date,
        default: new Date()
    },
    praisenum: Number,      //点赞量
    praise: {         //赞
        type: Boolean,
        default: false
    },     //赞
    collect: {         //收藏
        type: Boolean,
        default: false
    },
    starttime: String,     //约定时间
    endtime: String,       //截止时间
    address: String,     //约定地点
    comment: Array,         //评论
    forwardnum: Number,     //转发量
})

let runModel = mongoose.model("run", runSchema, "run")

//意见反馈列表
let feedbackSchema = new mongoose.Schema({
    test: String,        //描述问题
    imgs: Array,         //描述图片
    tel: String          //联系电话
})

let feedbackModel = mongoose.model("feedback", feedbackSchema, "rufeedbackn")

module.exports = { userModel, listModel, runModel, feedbackModel, phoneModel, statusModel }